package com.ewanghuiju.app.presenter.pintuan;

import com.ewanghuiju.app.base.RxPresenter;
import com.ewanghuiju.app.base.contract.pintuan.PintuanPingjiaContract;
import com.ewanghuiju.app.model.DataManager;
import com.ewanghuiju.app.model.bean.response.PingjiaListResponBean;
import com.ewanghuiju.app.model.http.response.Optional;
import com.ewanghuiju.app.util.RxUtil;
import com.ewanghuiju.app.widget.CommonSubscriber;

import java.util.List;

import javax.inject.Inject;

/**
 * @author sj  qq:751943509
 * @class 评价列表
 * @time 2020/2/16
 */
public class PintuanPingjiaPresenter extends RxPresenter<PintuanPingjiaContract.View> implements PintuanPingjiaContract.Presenter {

    private DataManager mDataManager;

    @Inject
    public PintuanPingjiaPresenter(DataManager mDataManager) {
        this.mDataManager = mDataManager;
    }

    @Override
    public void getData() {

    }

    /**
     * 获取评价列表
     *
     * @param page
     * @param goods_id
     */
    @Override
    public void getPjList(int page, String goods_id) {
        //获取评价列表
        addSubscribe(mDataManager.ptievaluationList(page, "", goods_id)
                .compose(RxUtil.rxSchedulerHelper())
                .compose(RxUtil.handleMyResultCannull())
                .subscribeWith(new CommonSubscriber<Optional<List<PingjiaListResponBean>>>(mView) {
                    @Override
                    public void onNext(Optional<List<PingjiaListResponBean>> optional) {
                        if (mView != null)
                            mView.showContent(optional.getIncludeNull());
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        if (mView != null)
                            mView.showContentError();
                    }
                })
        );

    }
}
